package com.qf.hospital.service.impl;

import com.qf.hospital.entity.RegisteredType;
import com.qf.hospital.mapper.RegisteredTypeMapper;
import com.qf.hospital.service.RegisteredTypeService;
import com.qf.hospital.vo.RegisteredTypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zjw
 * @description
 * @date 2021/10/20 11:52
 */
@Service
public class RegisteredTypeServiceImpl implements RegisteredTypeService {

    @Autowired
    private RegisteredTypeMapper registeredTypeMapper;

    @Override
    public List<RegisteredTypeVO> selectRegisteredType() {
        List<RegisteredType> registeredTypeList = registeredTypeMapper.selectByExample(null);

        List<RegisteredTypeVO> data = new ArrayList<>();
        registeredTypeList.forEach(r -> {
            data.add(new RegisteredTypeVO(r.getId(),r.getType()));
        });

        return data;
    }

    @Override
    public Integer findPriceByRegisteredId(Integer registeredId) {
        // 查询&返回
        return registeredTypeMapper.findPriceByRegisteredId(registeredId);
    }
}
